<template>
    <div id='user-index'>
       <!--  <h1 class="card-title">
           <span>用户</span>
       </h1> -->
        <!-- <div class="user-data loading-min-height">
            <loading v-if='loading_count' mode='full'></loading>
            <transition name='fade'>
                <ul class="user-data__list" v-if='hasUserCount'>
                    <li class="user-data__item">
                        <span> {{ userCount.newCount }} </span>
                        <p>今日新增用户</p>
                    </li>
                    <li class="user-data__item">
                        <span> {{ userCount.totalCount }} </span>
                        <p>总用户数</p>
                    </li>
                </ul>
            </transition>
        </div> -->

        <tab-box>
            <tab name='全部用户'>
                <div class="order-form form-table">
                    <div class="form-content">
                        <div class="form-item">
                            <div class="form-item__key">手机号</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入手机号码" v-model='mobile'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">姓名</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入姓名" v-model='name'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">渠道</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入渠道" v-model='channel'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">排序规则</div>
                            <span class="form-item__value">
                                <select-group v-model='sort'>
                                    <select-option value='' text='默认'></select-option>
                                    <select-option value='0' text='正在发布的求借款次数'></select-option>
                                    <select-option value='1' text='借款成功率'></select-option>
                                    <select-option value='2' text='借款申请次数'></select-option>
                                    <select-option value='3' text='正在发布的出借次数'></select-option>
                                    <select-option value='4' text='出借通过率'></select-option>
                                    <select-option value='5' text='出借被申请次数'></select-option>
                                </select-group>
                            </span>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">排序顺序</div>
                            <span class="form-item__value">
                                <select-group v-model='sequence'>
                                    <select-option value='0' text='正序'></select-option>
                                    <select-option value='1' text='倒序'></select-option>
                                </select-group>
                            </span>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">开始日期</div>
                            <div class="form-item__value">
                                <date-picker
                                    v-model="dateFrom"
                                    color='#757575'
                                    :placeholder='`选择日期`'></date-picker>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">结束日期</div>
                            <div class="form-item__value">
                                <date-picker
                                    v-model="dateTo"
                                    color='#757575'
                                    :placeholder='`选择日期`'></date-picker>
                            </div>
                        </div>
                    </div>
                    <div @click='getList(1)' class="form-button"><span class="form-button__item button">搜索</span></div>
                </div>
                <div class="loading-min-height">
                    <loading v-if='loading' mode='full'></loading>
                    <transition name='fade'>
                        <p class='no-data' v-if='!loading && !records.length'>暂无数据</p>
                        <div class="table-list" v-if='records.length'>
                            <table>
                                <thead class="table-list__head">
                                    <tr>
                                        <th>手机号</th>
                                        <th>姓名</th>
                                        <th>正在发布求借款次数</th>
                                        <th>申请率</th>
                                        <th>申请人数</th>
                                        <th>正在发布出借次数</th>
                                        <th>通过率</th>
                                        <th>被申请次数</th>
                                        <th>当前信用报告状态</th>
                                        <th>渠道</th>
                                        <th>推荐位置</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody class='table-list__body have-border'>
                                    <tr v-for='item in records'>
                                        <td>{{ item.mobile || placeholder }}</td>
                                        <td>{{ item.realName || placeholder }}</td>
                                        <td>
                                            {{ item.countBorrowing || placeholder }} 
                                            <span v-if='item.ispublic === false'> (未公开) </span>
                                        </td>
                                        <td>{{ Math.round(item.borrowSuccessRate * 100).toFixed(2) }}%</td>
                                        <td>{{ item.countApplyBorrow || placeholder }}</td>
                                        <td>{{ item.countLending || placeholder }}</td>
                                        <td>{{ Math.round(item.lendPassRate * 100).toFixed(2) }}%</td>
                                        <td>{{ item.lendApplyCount || placeholder }}</td>
                                        <td>{{ item.creditReportStatusStr || placeholder }}</td>
                                        <td>{{ item.channel || placeholder }}</td>
                                        <td>
                                            <div>小b：{{ item.lendRecommendPosition || placeholder }} </div>
                                            <div>小c：{{ item.borrowRecommendPosition || placeholder }} </div>
                                        </td>
                                        <td>
                                            <div class='option-box'>
                                                <span class='option-button' 
                                                    v-if='item.isRecommend' 
                                                    @click='showModalCancleRecommend(item)'>取消推荐</span>
                                                <span class='option-button' 
                                                    v-else  
                                                    @click='showModalRecommend(item)'>推荐</span>
                                                <span class='option-button' 
                                                    :class="{'event-disabled disabled' : !item.isRecommend}"
                                                    @click='showModalRecommend(item)'>推荐设置</span>
                                                <span class='option-button' 
                                                    :class="{'event-disabled disabled' : item.accountState == 'UNUSUAL'}"
                                                    @click='showModalFreeze(item)'>冻结</span>
                                                <span class='option-button' @click='showModalDetail(item)'>详细</span>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <pagination
                                :current-page='listInfo.pageNum'
                                :total-page='listInfo.totalPage'
                                @pageChange='getList'></pagination>
                        </div>
                    </transition>
                </div>
            </tab>
            <tab name='小b推荐'>
                <div class="order-form form-table">
                    <div class="form-content">
                        <div class="form-item">
                            <div class="form-item__key">手机号</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入手机号码" v-model='mobile1'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">姓名</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入姓名" v-model='name1'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">渠道</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入渠道" v-model='channel1'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">开始日期</div>
                            <div class="form-item__value">
                                <date-picker
                                    v-model="dateFrom1"
                                    color='#757575'
                                    :placeholder='`选择日期`'></date-picker>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">结束日期</div>
                            <div class="form-item__value">
                                <date-picker
                                    v-model="dateTo1"
                                    color='#757575'
                                    :placeholder='`选择日期`'></date-picker>
                            </div>
                        </div>
                    </div>
                    <div @click='getList1(1)' class="form-button"><span class="form-button__item button">搜索</span></div>
                </div>
                <div class="loading-min-height">
                    <loading v-if='loading1' mode='full'></loading>
                    <transition name='fade'>
                        <p class='no-data' v-if='!loading1 && !records1.length'>暂无数据</p>
                        <div class="table-list" v-if='records1.length'>
                            <table>
                                <thead class="table-list__head">
                                    <tr>
                                        <th>推荐位置</th>
                                        <th>手机号</th>
                                        <th>姓名</th>
                                        <th>正在发布求借款次数</th>
                                        <th>正在发布出借次数</th>
                                        <th>当前信用报告状态</th>
                                        <th>渠道</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody class='table-list__body have-border'>
                                    <tr v-for='item in records1'>
                                        <td>{{ item.lendRecommendPosition || placeholder }}</td>
                                        <td>{{ item.mobile || placeholder }}</td>
                                        <td>{{ item.realName || placeholder }}</td>
                                        <td>{{ item.countBorrowing || placeholder }}</td>
                                        <td>{{ item.countLending || placeholder }}</td>
                                        <td>{{ item.creditReportStatusStr || placeholder }}</td>
                                        <td>{{ item.channel || placeholder }}</td>
                                        <td>
                                            <div class='option-box'>
                                                <span class='option-button' 
                                                    v-if='item.isRecommend' 
                                                    @click='showModalCancleRecommend(item)'>取消推荐</span>
                                                <span class='option-button' 
                                                    v-else  
                                                    @click='showModalRecommend(item)'>推荐</span>
                                                <span class='option-button' 
                                                    :class="{'event-disabled disabled' : !item.isRecommend}"
                                                    @click='showModalRecommend(item)'>推荐设置</span>
                                                <span class='option-button' @click='showModalDetail(item)'>详细</span>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <pagination
                                :current-page='listInfo1.pageNum'
                                :total-page='listInfo1.totalPage'
                                @pageChange='getList1'></pagination>
                        </div>
                    </transition>
                </div>
            </tab>
            <tab name='小c推荐'>
                <div class="order-form form-table">
                    <div class="form-content">
                        <div class="form-item">
                            <div class="form-item__key">手机号</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入手机号码" v-model='mobile2'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">姓名</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入姓名" v-model='name2'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">渠道</div>
                            <div class="form-item__value">
                                <input type="tel" placeholder="请输入渠道" v-model='channel2'>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">开始日期</div>
                            <div class="form-item__value">
                                <date-picker
                                    v-model="dateFrom2"
                                    color='#757575'
                                    :placeholder='`选择日期`'></date-picker>
                            </div>
                        </div>
                        <div class="form-item">
                            <div class="form-item__key">结束日期</div>
                            <div class="form-item__value">
                                <date-picker
                                    v-model="dateTo2"
                                    color='#757575'
                                    :placeholder='`选择日期`'></date-picker>
                            </div>
                        </div>
                    </div>
                    <div @click='getList2(1)' class="form-button"><span class="form-button__item button">搜索</span></div>
                </div>
                <div class="loading-min-height">
                    <loading v-if='loading2' mode='full'></loading>
                    <transition name='fade'>
                        <p class='no-data' v-if='!loading2 && !records2.length'>暂无数据</p>
                        <div class="table-list" v-if='records2.length'>
                            <table>
                                <thead class="table-list__head">
                                    <tr>
                                        <th>推荐位置</th>
                                        <th>手机号</th>
                                        <th>姓名</th>
                                        <th>正在发布求借款次数</th>
                                        <th>正在发布出借次数</th>
                                        <th>当前信用报告状态</th>
                                        <th>渠道</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody class='table-list__body have-border'>
                                    <tr v-for='item in records2'>
                                        <td>{{ item.borrowRecommendPosition || placeholder }}</td>
                                        <td>{{ item.mobile || placeholder }}</td>
                                        <td>{{ item.realName || placeholder }}</td>
                                        <td>{{ item.countBorrowing || placeholder }}</td>
                                        <td>{{ item.countLending || placeholder }}</td>
                                        <td>{{ item.creditReportStatusStr || placeholder }}</td>
                                        <td>{{ item.channel || placeholder }}</td>
                                        <td>
                                            <div class='option-box'>
                                                <span class='option-button' 
                                                    v-if='item.isRecommend' 
                                                    @click='showModalCancleRecommend(item)'>取消推荐</span>
                                                <span class='option-button' 
                                                    v-else  
                                                    @click='showModalRecommend(item)'>推荐</span>
                                                <span class='option-button' 
                                                    :class="{'event-disabled disabled' : !item.isRecommend}"
                                                    @click='showModalRecommend(item)'>推荐设置</span>
                                                <span class='option-button' @click='showModalDetail(item)'>详细</span>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <pagination
                                :current-page='listInfo2.pageNum'
                                :total-page='listInfo2.totalPage'
                                @pageChange='getList2'></pagination>
                        </div>
                    </transition>
                </div>
            </tab>
        </tab-box>

        <modal  
            :show='show_modal_detail' 
            title='详细' 
            cancle-text=''
            confirm-text=''
            @close='show_modal_detail=false'>
            <ul v-if='curDetail'>
                <li class="result-info__item">
                    <div class="result-info__key">手机号码</div>
                    <div class="result-info__value">{{curDetail.mobile || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">姓名</div>
                    <div class="result-info__value">{{curDetail.realName || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">正在发布求借款次数/总发布次数</div>
                    <div class="result-info__value">{{curDetail.countBorrowing}}/{{curDetail.countBorrow}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">正在发布出借次数/总发布次数</div>
                    <div class="result-info__value">{{curDetail.countLending}}/{{curDetail.countLend}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">借入总金额/待还</div>
                    <div class="result-info__value">{{curDetail.borrowAmount | toYuan}}/{{curDetail.borrowWaitRepayAmount | toYuan}}元</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">出借总金额/待收</div>
                    <div class="result-info__value">{{curDetail.lendAmount | toYuan}}/{{curDetail.lendWaitComeAmount | toYuan}}元</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">身份证号码</div>
                    <div class="result-info__value">{{curDetail.idNumber || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">银行卡信息</div>
                    <div class="result-info__value">{{curDetail.bankName || placeholder}} - {{curDetail.bankCardNo || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">是否有信用报告</div>
                    <div class="result-info__value">
                        {{curDetail.isHaveCreditReport || placeholder}} &nbsp;&nbsp; 
                        <span @click='goReportDetail' class='report-detail-button' v-show='curDetail.isHaveCreditReport == "有信用报告"'>查看信用报告</span>
                    </div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">信用报告状态</div>
                    <div class="result-info__value">
                        {{curDetail.creditReportStatusStr || placeholder}}
                    </div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">渠道号</div>
                    <div class="result-info__value">{{curDetail.channel || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">是否推荐</div>
                    <div class="result-info__value">{{curDetail.isRecommendStr || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">注册时间</div>
                    <div class="result-info__value">{{curDetail.createdAt | dateFormat}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">年龄</div>
                    <div class="result-info__value">{{curDetail.age || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">性别</div>
                    <div class="result-info__value">{{curDetail.gender || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">地址位置 省/市</div>
                    <div class="result-info__value">{{curDetail.province || placeholder}}</div>
                </li>
                <li class="result-info__item">
                    <div class="result-info__key">当前账户余额</div>
                    <div class="result-info__value">{{curDetail.balance | toYuan}}元</div>
                </li>
            </ul>
        </modal>

        <modal  
            :show='show_modal_recommend'
            :loading='loading_set_recommend' 
            :closeButton='false'
            title='推荐' 
            @close='show_modal_recommend=false'
            @confirm='setRecommendTip'>
            <ul class='modal-recommend'>
                <li class="form-item">
                    <span class="form-item__key">推荐类型</span> 
                    <div class="result-info__value">
                        <select-group v-model='recommendType'>
                            <select-option value='' text='请选择推荐类型'></select-option>
                            <select-option value='lend' text='小b推荐'></select-option>
                            <select-option value='borrow' text='小c推荐'></select-option>
                        </select-group>
                    </div>
                </li>
                <li class="form-item" v-if='recommendType.value == "borrow"'>
                    <span class="form-item__key">推荐位置</span>
                    <div class="result-info__value">
                        <select-group key='all-borrow' v-model='curRecommend' :maxHeight='250'>
                            <select-option value='' text='添加到最后'>添加到最后</select-option>
                            <select-option v-for='item in borrowNumber' :key='item' :value='item' :text='item'></select-option>
                        </select-group>
                    </div>
                </li>
                <li class="form-item" v-if='recommendType.value == "lend"'>
                    <span class="form-item__key">推荐位置</span>
                    <div class="result-info__value">
                        <select-group key='all-lend' v-model='curRecommend' :maxHeight='250'>
                            <select-option value='' text='添加到最后'>添加到最后</select-option>
                            <select-option v-for='item in lendNumber' :key='item' :value='item' :text='item'></select-option>
                        </select-group>
                    </div>
                </li>
            </ul>
        </modal>

        <modal  
            :show='show_modal_cancle_recommend'
            :loading='loading_cancle_recommend' 
            :closeButton='false'
            title='取消推荐' 
            @close='show_modal_cancle_recommend=false'
            @confirm='cancleRecommend'>
            <ul class='modal-recommend'>
                <li class="form-item">
                    <span class="form-item__key">取消推荐类型</span> 
                    <div class="result-info__value">
                        <select-group v-model='cancleRecommendType'>
                            <select-option value='' text='请选择取消推荐类型'></select-option>
                            <select-option v-if='curItem.lendRecommendPosition' value='lend' text='小b推荐'></select-option>
                            <select-option v-if='curItem.borrowRecommendPosition' value='borrow' text='小c推荐'></select-option>
                        </select-group>
                    </div>
                </li>
            </ul>
        </modal>

        <confirm
            :show='showConfirm'
            :title='title'
            :tip='tip'
            @confirm='confirmTip'
            @close='showConfirm = false'>
        </confirm>

        <confirm
            :show='showFreeze'
            title='冻结用户'
            tip='是否冻结该用户？'
            :loading='loading_freeze'
            @confirm='freeze'
            @close='showFreeze = false'>
        </confirm>
    </div>
</template>

<script>
    import { Promise } from 'es6-promise'
    import footerBar from '../components/FooterBar.vue'
    import selectGroup from '../components/SelectGroup.vue'
    import selectOption from '../components/SelectOption.vue'
    import radioGroup from '../components/RadioGroup.vue'
    import datePicker from '../components/DatePicker.vue'
    import areaSelect from '../components/AreaSelect.vue'
    import radio from '../components/Radio.vue'
    import loading from '../components/Loading.vue'
    import tabBox from '../components/TabBox.vue'
    import tab from '../components/Tab.vue'
    import checkBox from '../components/CheckBox.vue'
    import toolTip from '../components/ToolTip.vue'
    import modal from '../components/Modal.vue'
    import confirm from '../components/Confirm.vue'
    import buttonLoading from '../components/ButtonLoading.vue'
    import pagination from '../components/Pagination.vue'
    import dateFormat from '../filters/filter-dateFormat'
    import toYuan from '../filters/filter-toYuan'
    import  { mapGetters, mapActions }  from 'vuex'
    import { addLenderValidation, resetAccountPasswordValidation, operatorEditValidation } from '../validation/validation'
    import { allApi, lenderApi } from '../api/api'
    import moment from 'moment'


    export default {
        components:{
            footerBar,
            selectGroup,
            selectOption,
            radioGroup,
            tabBox,
            tab,
            radio,
            checkBox,
            areaSelect,
            loading,
            toolTip,
            modal,
            confirm,
            buttonLoading,
            pagination,
            datePicker
        },
        filters:{
            dateFormat,
            toYuan,
            booleanToStr(boolean){
                if(boolean === true){
                    return '是'
                }
                else{
                    return '否'
                }
            }
        },
        data() {
            return {
                placeholder:'--',
                recommend:0,
                curItem:{},
                showConfirm:false,
                showFreeze:false,
                sequence:{
                    value:'0',
                    text:'正序'
                },
                sort:{
                    value:'',
                    text:'默认'
                },
                title:'',
                tip:'',
                curRecommend:{
                    value:'',
                    text:'添加到最后'
                },
                curUserId:'',
                cancleRecommendType:{
                    value:'',
                    text:'请选择取消推荐类型'
                },
                recommendType:{
                    value:'',
                    text:'请选择推荐类型'
                },
                lendNumber:'',
                borrowNumber:'',
                show_modal_cancle_recommend:false,
                show_modal_recommend:false,
                show_modal_recommend1:false,
                show_modal_recommend2:false,
                show_modal_detail:false,
                loading_set_recommend:false,
                loading_freeze:false,
                loading_cancle_recommend:false,
                channel:'',
                channel1:'',
                channel2:'',
                name:'',
                name1:'',
                name2:'',
                userCount:'',
                curDetail:'',
                listInfo:{},
                listInfo1:{},
                listInfo2:{},
                records:[],
                records1:[],
                records2:[],
                dateFrom:'',
                dateFrom1:'',
                dateFrom2:'',
                dateTo:'',
                dateTo1:'',
                dateTo2:'',
                mobile:'',
                mobile1:'',
                mobile2:'',
                loading:true,
                loading1:true,
                loading2:true,
                loading_count:true,
            }
        },
        computed:{
            ...mapGetters([
                'msgTip',
                'localInfo'
            ]),
            currentPage(){
                if(_.isEmpty(this.listInfo)) return 1
                return this.listInfo.pageNum
            },
            hasUserCount(){
                return !_.isEmpty(this.userCount)
            },
            noEditObject(){
                return _.isEmpty(this.editObject)
            },
            noInvoiceInfo(){
                return _.isEmpty(this.invoiceInfo)
            }
        },
        methods:{
            // actions
            ...mapActions([
                'showLoading',
                'hideLoading',
                'setMsgTip'
            ]),

            // filters
            timestampToDate(timestamp){
                if(!timestamp) return this.placeholder
                return moment(timestamp).format('YYYY-MM-DD')
            },

            // function


            showModalDetail(item){
                this.show_modal_detail = true
                this.curDetail = item
            },
            showModalRecommend(item){

                this.curRecommend = {
                    value:'',
                    text:'添加到最后'
                },
                this.recommendType = {
                    value:'',
                    text:'请选择推荐类型'
                }
                this.curItem = item
                this.curUserId = item.userId

                this.show_modal_recommend = true
                
            },
            showModalFreeze(item){
                this.curItem = item
                this.curUserId = item.userId

                this.showFreeze = true
                
            },
            showModalCancleRecommend(item){
                this.show_modal_cancle_recommend = true
                this.curItem = item
                if(!item.borrowRecommendPosition && item.lendRecommendPosition){
                    this.cancleRecommendType = {
                        value:'lend',
                        text:'小b推荐'
                    }
                    return
                }
                if(item.borrowRecommendPosition && !item.lendRecommendPosition){
                    this.cancleRecommendType = {
                        value:'borrow',
                        text:'小c推荐'
                    }
                    return
                }
                this.cancleRecommendType = {
                    value:'',
                    text:'请选择取消推荐类型'
                }
            },
            getNumber(){
                allApi.borrowCount()
                .then(result=>{
                    this.borrowNumber = result
                })
                .catch(error => {
                    console.error(error)
                })
                allApi.lendCount()
                .then(result=>{
                    this.lendNumber = result
                })
                .catch(error => {
                    console.error(error)
                })
            },
            getList(num){
                this.loading = true
                let params = {
                    pageSize:10,
                    pageNo:num,
                    stringdateFrom:this.dateFrom,
                    stringdateTo:this.dateTo,
                    mobile:this.mobile,
                    name:this.name,
                    channelStr:this.channel,
                    sortString:this.sort.value,
                    sequence:this.sequence.value,
                }
                allApi.userList(params)
                .then(result=>{
                    this.loading = false
                    this.listInfo = result
                    this.records = result.records
                    if(result.totalPage < result.pageNum){
                        this.getList(result.totalPage)
                    }
                })
                .catch(error => {
                    console.error(error)
                    this.loading = false
                })
            },
            getList1(num){
                this.loading1 = true
                let params = {
                    pageSize:10,
                    recommedStr:'b',
                    pageNo:num,
                    stringdateFrom:this.dateFrom1,
                    stringdateTo:this.dateTo1,
                    mobile:this.mobile1,
                    name:this.name1,
                    channelStr:this.channel1,
                }
                allApi.userList(params)
                .then(result=>{
                    this.loading1 = false
                    this.listInfo1 = result
                    this.records1 = result.records
                    if(result.totalPage < result.pageNum){
                        this.getList1(result.totalPage)
                    }
                })
                .catch(error => {
                    console.error(error)
                    this.loading1 = false
                })
            },
            getList2(num){
                this.loading2 = true
                let params = {
                    pageSize:10,
                    recommedStr:'c',
                    pageNo:num,
                    stringdateFrom:this.dateFrom1,
                    stringdateTo:this.dateTo1,
                    mobile:this.mobile1,
                    name:this.name1,
                    channelStr:this.channel1,
                }
                allApi.userList(params)
                .then(result=>{
                    this.loading2 = false
                    this.listInfo2 = result
                    this.records2 = result.records
                    if(result.totalPage < result.pageNum){
                        this.getList2(result.totalPage)
                    }
                })
                .catch(error => {
                    console.error(error)
                    this.loading2 = false
                })
            },
            setRecommendTip(type){
                if(this.recommendType.value == 'borrow' && this.curItem.countBorrowing == 0){
                    this.title = '确认推荐小c'
                    this.tip = '该用户未发布借款，确认推荐？'
                    this.showConfirm = true
                    return
                }
                if(this.recommendType.value == 'lend' && this.curItem.countLending == 0){
                    this.title = '确认推荐小b'
                    this.tip = '该用户未发布出借，确认推荐？'
                    this.showConfirm = true
                    return
                }

                this.setRecommend()

            },
            confirmTip(){
                this.showConfirm = false
                this.setRecommend()
            },
            setRecommend(){
                this.loading_set_recommend = true
                let params = {
                    userId:this.curUserId,
                    priorityNo:this.curRecommend.value
                }
                if(this.recommendType.value == 'borrow'){
                    allApi.setBorrowRecommend(params)
                    .then(result=>{
                        this.loading_set_recommend = false
                        this.show_modal_recommend = false
                        this.show_modal_recommend1 = false
                        this.show_modal_recommend2 = false
                        this.getList(this.listInfo.pageNum)
                        this.getList2(this.listInfo2.pageNum)
                        this.getNumber()
                    })
                    .catch(error => {
                        console.error(error)
                        this.loading_set_recommend = false
                    })
                    return
                }
                if(this.recommendType.value == 'lend'){
                    allApi.setLendRecommend(params)
                    .then(result=>{
                        this.loading_set_recommend = false
                        this.show_modal_recommend = false
                        this.show_modal_recommend1 = false
                        this.show_modal_recommend2 = false
                        this.getList(this.listInfo.pageNum)
                        this.getList1(this.listInfo1.pageNum)
                        this.getNumber()
                    })
                    .catch(error => {
                        console.error(error)
                        this.loading_set_recommend = false
                    })
                }
            },
            cancleRecommend(item){
                let params = {
                    userId:this.curItem.userId,
                }
                if(this.cancleRecommendType.value == 'borrow'){
                    this.loading_cancle_recommend = true
                    allApi.delBorrowRecommend(params)
                    .then(result=>{
                        this.loading_cancle_recommend = false
                        this.show_modal_cancle_recommend = false
                        this.getList(this.listInfo.pageNum)
                        this.getList2(this.listInfo2.pageNum)
                        this.getNumber()
                    })
                    .catch(error => {
                        console.error(error)
                        this.loading_cancle_recommend = false
                    })
                    return
                }
                if(this.cancleRecommendType.value == 'lend'){
                    this.loading_cancle_recommend = true
                    allApi.delLendRecommend(params)
                    .then(result=>{
                        this.loading_cancle_recommend = false
                        this.show_modal_cancle_recommend = false
                        this.getList(this.listInfo.pageNum)
                        this.getList1(this.listInfo1.pageNum)
                        this.getNumber()
                    })
                    .catch(error => {
                        console.error(error)
                        this.loading_cancle_recommend = false
                    })
                }
                else{
                    this.setMsgTip({
                        text:'请选择取消推荐类型',
                        type:'warn'
                    })
                }
            },
            goReportDetail(){
                window.open(`https://youjie.kongapi.com/#/user-credit-report-detail/${this.curDetail.creditReportNo}`,'','width=375,height=667')
            },
            getAccount(){
                this.loading_count = true
                allApi.userCount()
                .then(result=>{
                    this.loading_count = false
                    this.userCount = result
                })
                .catch(error => {
                    console.error(error)
                    this.loading_count = false
                })
            },
            freeze(){
                this.loading_freeze = true
                allApi.freezeUser({
                    mobile:this.curItem.mobile
                })
                .then(result=>{
                    this.loading_freeze = false
                    this.setMsgTip({
                        text:'冻结用户成功！',
                        type:'success'
                    })
                })
                .catch(error => {
                    console.error(error)
                    this.loading_freeze = false
                })
            }
        },
        created(){
            // this.getAccount()
            this.getList(1)
            this.getList1(1)
            this.getList2(1)
            this.getNumber()
        }
    }
</script>

<style lang="scss">
    @import "../sass/variables";
    @import "../sass/extends";
    @import "../sass/mixins";

    #user-index{
        padding:0 40px 20px 40px;
        box-sizing:border-box;
        overflow:auto;
        .user-data{
            padding-bottom: 20px;
        }
        .user-data__list{
            display:flex;
            padding-top: 20px;
            min-height:140px;
        }
        .user-data__item{
            display:flex;
            flex-direction: column;
            justify-content:center;
            align-items:center;
            width: 200px;
            height:120px;
            border:1px solid $sectionColor;
            border-radius:4px;
            box-shadow:rgba(0, 0, 0, 0.03) 0px 1px 6px, rgba(0, 0, 0, 0.04) 0px 1px 4px;
            margin-right:20px;
            span{
                display: block;
                font-size: 30px;
                color:$green;
            }
            p{
                padding-top: 10px;
            }
        }
        .report-detail-button{
            color:$green;
            cursor:pointer;
        }
        .modal-recommend{
            .form-item__value{
                flex:1;
            }
            min-height:330px;
        }
    }
</style>
